#include <iostream>
//-----------------------------------------------
#include "Window.h"
#include "Renderer.h"
//-----------------------------------------------
#include "MyEngine.h"
//-----------------------------------------------
// Declaraciones.
Engine::Engine(HINSTANCE hInstance,unsigned int uiWidth,unsigned int uiHeight):
m_hInstance(hInstance),
	m_uiWidth(uiWidth),
	m_uiHeight(uiHeight),
	m_pkWindow(new Window(hInstance)),
	m_pkRenderer(new Renderer()){
		//nada
}

Engine::~Engine(){
	delete m_pkRenderer;
	m_pkRenderer=NULL;

	delete m_pkWindow;
	m_pkWindow = NULL;

}
bool Engine	::init (){
	//create window
	if(!m_pkWindow->createWindow(m_uiWidth,m_uiHeight)){
		return false;
	}
	//init rendering system
	if(!m_pkRenderer->init(m_pkWindow->getHWND())){
		return false;
	}
	return true;
}
void Engine::run(){
	//frame loop

	bool bDone= false;
	MSG kMsg;
	while(!bDone){
		//render frame
		m_pkRenderer->beginFrame();
		m_pkRenderer->endFrame();

		if(PeekMessage(&kMsg,NULL,0,0,PM_REMOVE))
		{
			//check if we have to exit the game
			switch(kMsg.message)
			{
			case WM_QUIT:
				{
					bDone=true;
					break;
				}
			}
			TranslateMessage(&kMsg);
			DispatchMessage(&kMsg);
		}
	}


}
//-----------------------------------------------